﻿using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using PMS.Data.DbUtils.DataMapping;
using PMS.Data.Entities.SystemModules;

namespace PMS.Data.EntityMap.SystemModules
{
    /// <summary>
    /// Represents a ModuleButtons mapping configuration
    /// </summary>
    public partial class ModuleButtonsMap : PMSEntityTypeConfiguration<ModuleButton>
    {
        #region Methods

        /// <summary>
        /// Configures the entity
        /// </summary>
        /// <param name="builder">The builder to be used to configure the entity</param>
        public override void Configure(EntityTypeBuilder<ModuleButton> builder)
        {
            builder.ToTable("sys_modulebuttons");
            builder.HasKey(modulebtn => modulebtn.Id);

            builder.Property(modulebtn => modulebtn.Name).HasMaxLength(128).IsRequired();
            builder.Property(modulebtn => modulebtn.DisplayName).HasMaxLength(128);
            builder.Property(modulebtn => modulebtn.ButtonDescription).HasMaxLength(512);
            builder.Property(modulebtn => modulebtn.GroupType).IsRequired();
            builder.Property(modulebtn => modulebtn.HtmlButtonCSSClass).HasMaxLength(1024);
            builder.Property(modulebtn => modulebtn.HtmlIconCSSClass).HasMaxLength(1024);
            builder.Property(modulebtn => modulebtn.EventName).HasMaxLength(128).IsRequired();
            builder.Property(modulebtn => modulebtn.DisplayMode).IsRequired();
            builder.Property(modulebtn => modulebtn.DisplayOrder).IsRequired();
            builder.Property(modulebtn => modulebtn.IsActive).IsRequired();
            builder.Property(modulebtn => modulebtn.AuthorizeRequired).IsRequired();

            builder.Ignore(modulebtn => modulebtn.CreatedOnTimeUtc);
            builder.Ignore(modulebtn => modulebtn.UpdatedOnTimeUtc);
            base.Configure(builder);
        }

        #endregion
    }
}
